function Tab (id, tabObj) {
  this.wrap = document.getElementById(id)//外套
  this.wrap.style.width = tabObj.width + "px";
  console.log(this.wrap)
  this.lis = this.wrap.querySelectorAll("li");
  console.log(this.lis)
  this.divs = document.querySelectorAll("#" + id + ">div>div")//#tab>div>div
  console.log(this.divs)
  this.init = function () {//初始化
    var that = this;
    for (var i = 0; i < this.lis.length; i++) {
      this.lis[i].index = i;//给每个li元素绑定下标
      this.lis[i].onclick = function () {
        that.change(this)//把当前点击的li元素传递
      }
    }
  }
  this.init()//初始化调用
}
// 切换方法
Tab.prototype.change = function (ele) {//ele代表当前点击的li
  for (var j = 0; j < this.divs.length; j++) {
    this.divs[j].style.display = "none"
    this.lis[j].className = ""
  }
  this.divs[ele.index].style.display = "block";
  ele.className = "active";
}
